-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Current library's bib file is removed from the unlinked file search results #9755
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Congratulations on your first contribution! 💯
Can you also please add a Test case for this? It should be pretty straightforward to add it in UnlinkedFilesCrawlerTest
Just create a new BibDatabasContext and set the path
@@ -37,6 +39,7 @@ public DatabaseFileLookup(BibDatabaseContext databaseContext, FilePreferences fi | |||
for (BibEntry entry : databaseContext.getDatabase().getEntries()) { | |||
fileCache.addAll(parseFileField(entry)); | |||
} | |||
this.pathOfDatabase = databaseContext.getDatabasePath().orElseThrow(() -> new NullPointerException("Database null")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather say, return an empty string in case no database path is present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the opportunity! : )
I thought that an instance of DataBaseLookup instance should not exist if a database path is not present. Why not throw an exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There could be an edge case for a shared database, that is synced with an external SQL database but not necessarily stored on disk but only kept/edited in memory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see
src/test/java/org/jabref/gui/externalfiles/UnlinkedFilesCrawlerTest.java
Outdated
Show resolved
Hide resolved
public Path getPathOfDatabase() { | ||
return pathOfDatabase; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most clean code would be to use Optional<Path>
here. However, the only place using this would be more complex. @Siedlerchr Any oppinion here?
If this is kept as is, the JavaDoc comment should be put here
@returns "" if the Path does not exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep as is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just wrong. A Path object can never be an empty string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should return null
then? Then, the calling code would be "clean". Think this method is never reached if the database is not saved.
Thanks again for your contribution! Looking forward for seeing more from you :) |
Not at all, I enjoyed it! Thank you :) |
Fixes #9735
Compulsory checks